package edu.njust.controller;

import edu.njust.Service.attribute.AttributeService;
import edu.njust.controller.depcontroller.Code;
import edu.njust.controller.depcontroller.Result;
import edu.njust.domain.attribute.Attribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
    该类对应的是从数据库Attribute中取出总的类型，
    不能传递参数
    根据路径名取得对应的类型
 */


@RestController
@RequestMapping(value = "/AttributeController")
public class AttributeController {
    @Autowired
    private AttributeService attributeService;

    @GetMapping("/selectRoomState")
    public Result selectRoomState() {
        List<Attribute> attributes = attributeService.selectRoomState();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }
    @GetMapping("/selectRoomLevel")
    public Result selectRoomLevel() {
        List<Attribute> attributes = attributeService.selectRoomLevel();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }
    @GetMapping("/selectCommodityType")
    public Result selectCommodityType() {
        List<Attribute> attributes = attributeService.selectCommodityType();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectPayWay")
    public Result selectPayWay() {
        List<Attribute> attributes = attributeService.selectPayWay();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectGender")
    public Result selectGender() {
        List<Attribute> attributes = attributeService.selectGender();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectNation")
    public Result selectNation() {
        List<Attribute> attributes = attributeService.selectNation();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectPapers")
    public Result selectPapers() {
        List<Attribute> attributes = attributeService.selectPapers();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectEducationDegree")
    public Result selectEducationDegree() {
        List<Attribute> attributes = attributeService.selectEducationDegree();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectThingReason")
    public Result selectThingReason() {
        List<Attribute> attributes = attributeService.selectThingReason();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectNum")
    public Result selectNum() {
        List<Attribute> attributes = attributeService.selectNum();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectPredetermineState")
    public Result selectPredetermineState() {
        List<Attribute> attributes = attributeService.selectPredetermineState();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }

    @GetMapping("/selectIsBillID")
    public Result selectIsBillID() {
        List<Attribute> attributes = attributeService.selectIsBillID();
        Integer code = attributes != null ? Code.GET_OK : Code.GET_ERR;
        String msg = attributes != null ? "" : "数据查询失败，请重试！";
        return new Result(code,attributes, msg);

    }


}
